<p>
  <h1><%=h @receipt.store.company.name + ' ' + @receipt.rDate.to_s %></h1>
</p>
<p>
	<%= link_to 'Back', receipts_path %> | <%= link_to 'New purchase', new_purchase_path %>
</p>
<h2>Purchases</h2>
<table>
  <tr>
    <th>Item</th>
    <th>Quantity</th>
    <th>Price</th>
	<th>Unit Price</th>
    <th>Tax rate</th>
    <th>Sale</th>
    <th>Coupon</th>
    <th>Notes</th>
	<th>Action</th>
  </tr>

<% for purchase in @receipt.purchases %>
  <tr class="<%= cycle("even", "odd") %>">
    <td><%=h purchase.item.brand.name rescue nil %> <%=h purchase.item.name %></td>
    <td class="numeric"><%=h purchase.quantity %> <%=h purchase.item.measure.unit rescue nil %></td>
    <td class="numeric"><%=h number_to_currency(purchase.price) %></td>
    <td class="numeric"><%=h number_to_currency(purchase.price/purchase.quantity) %> / <%=h purchase.item.measure.unit rescue nil %></td>
    <td class="numeric"><%=h number_to_percentage(purchase.tax_rate, :precision => 2) %></td>
    <td><%=h purchase.sale == true ? "Yes" : "No" %></td>
    <td class="numeric"><%=h number_to_currency(purchase.coupon) %></td>
    <td><%=h purchase.notes %></td>
    <td>
    	<%= link_to image_tag("view.gif"), purchase %>
		<%= link_to image_tag("edit.gif"), edit_purchase_path(purchase) %>
		<%= link_to image_tag("delete.gif"), purchase, :confirm => 'Are you sure?', :method => :delete %>
	</td>
  </tr>
<% end %>
</table>